<?php
/*
* Author: Nguyen Hai Nam
* Module: AboutUsModule
* Desc	: Introduce pick.vn and sidle pic
* Date	: 12/12/2011
*/
class ReferenceProjectsModule extends Pick_Core_Module{
	function ReferenceProjectsModule(){
		parent::Pick_Core_Module();
		# Languages
		$languages = new Pick_Core_Languages();
		$objectLanguages = "";
		$objectLanguages = $languages->getObjects(1, 'status = 1', array('position'=>'ASC'), '');
		if($objectLanguages){
			$objectLanguages = $objectLanguages['data'];	
		}#endif
		$this->template->assign("objectLanguages", $objectLanguages);
	}
	public function getContent(){

		$countries = new Pick_Dao_Countries();
		$project = new Pick_Dao_Project();
		$id = $this->request->get('id');
		$ajax = $this->request->get('ajax');
		if($ajax == true){
			$objProject = $project->getObject($id);
			if(is_object($objProject)){
				echo '
				var pjtJsn = 
					{
						"tit": "'.$objProject->getFieldLang('name').'",
						"img": "'.$objProject->getFullUrlAvatar('project', 'big').'",
						"desc": "'.$objProject->getFieldLang('abstract').'",
						"link": "'.$objProject->getUrl('referenceprojects').'"
					};
				';
			}else{
				echo '
				var pjtJsn = 
					{
						"tit": "",
						"img": "",
						"desc": "",
						"link": ""
					};
				';
			}
			exit;
		}
		if($id){
			$strcondition = "`countryid` = ".$id;
		}else{
			$strcondition = "1=1";	
		}
		
		$arrProject = $project->getObjects(1, $strcondition, array('date_created' => 'ASC'));
		$defaultProject = "";
		if(isset($arrProject['data'])){
			$defaultProject = $arrProject['data'][0];
		}
		$this->template->assign('defaultProject', $defaultProject);
		$this->template->assign('arrProject', $arrProject);
	}
}